﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using FantastPlatform.Framework.IModel;
using FantastPlatform.Framework.Model;
using FantastPlatform.Framework.IService;
using FantastPlatform.Framework;
using FantastPlatform.Framework.Core;
using FantastPlatform.Decision.IService;
using FantastPlatform.Decision.IModel;

namespace FantastPlatform.Decision.UI
{
    public partial class EmergencyFlow : BasePage
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }
        protected int GetFlowId()
        {
            int id = 0;
            int totalCount = 0;
            IFlowImplementService servicce = ServiceFactory.CreateService<IFlowImplementService>();
            Sort sort = new Sort() { Field = "StartTime", Order = Orders.Desc };
            IList<Sort> sorts = new List<Sort>();
            sorts.Add(sort);
            ConditionGroup group = new ConditionGroup();
            group.Conditions.Add(new Condition() { Field = "Enable", Type = typeof(bool).FullName, Value1 = "true" });
            group.Conditions.Add(new Condition() { Field = "StartTime", Type = typeof(DateTime).FullName, Value1 = DateTime.Now,Relation = Relations.And,Comparison= Comparisons.Lt });
          //  group.Conditions.Add(new Condition() { Field = "EndTime", Type = typeof(DateTime).FullName, Value1 = null, Relation = Relations.And, Comparison = Comparisons.Eq });
            IList<IFlowImplement> list = servicce.Search(group, sorts, int.MaxValue, 1, out totalCount);
            if (totalCount>0)
            {
                id = list[0].Id;
            }
            return id;

        }
      
    }
}